package com.song.ejf.page;

import java.util.List;

public class Page {

	private List<?> resultList;// 存放结果集
	private Integer pageSize = 10;// 每页显示多少条
	private Integer pageNow = 1;// 当前页
	private Integer total = 0;// 总记录数
	private Integer start = 0;// 获得开始下标
	private Integer end = 0;	//结束下标
	private Integer pageCount = 0;//总页数

	public List<?> getResultList() {
		return resultList;
	}

	public void setResultList(List<?> resultList) {
		this.resultList = resultList;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getPageNow() {
		return pageNow;
	}

	public void setPageNow(Integer pageNow) {
		this.pageNow = pageNow;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		pageCount = ((total % pageSize == 0) ? (total / pageSize) : (total / pageSize + 1));
		this.total = total;
	}

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	// 获取开始下标
	public int getStartIndex() {
		if (pageNow >= 0) {
			start = pageSize * (pageNow - 1);
		}
		return start;
	}
	
	//获取结束下标
	public int getEndIndex(){
		return getStartIndex()+pageSize+1;
	}
	
	public Integer getEnd() {
		return end;
	}

	public void setEnd(Integer end) {
		this.end = end;
	}

	public Integer getPageCount() {
		return pageCount;
	}

	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}

	@Override
	public String toString() {
		return "当前页:" + this.pageNow + "每页记录数:" + this.pageSize + "查询总记录数:"
				+ this.total + "分页开始下标:" + this.start + "分页数:"
				+ this.pageCount;
	}

}
